#pragma once

#include <QWidget>

class QMenu;
class SMenuButton : public QWidget
{
	Q_OBJECT
public:
	SMenuButton(QWidget* parent);
	void setCaption(const QString& txt) { m_caption = txt; }
	void setShowMenu(bool v) { m_showMenu = v; }
	void setIndex(int v) { m_index = v; }
	void showMenu(QMenu*);

signals:
	void clicked(int index);
	void hovered(int index);

protected:
	void mousePressEvent(QMouseEvent* event) override;
	void enterEvent(QEvent* event) override;
	void leaveEvent(QEvent* event) override;
	void paintEvent(QPaintEvent* event) override;
	bool eventFilter(QObject *watched, QEvent *event);
	
private:
	QString			m_caption;
	bool			m_showMenu = false;
	bool			m_hover = false;
	int				m_index = 0;
};